package de.ingo.app.mensa.v0_2.activities;

import de.ingo.app.mensa.v0_2.activities.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class StartScreen extends Activity {
	
	protected int _startTime 	= 2000; // wie viele ms wird der StartScreen angezeigt
	final String PAKET 			= "de.ingo.app.mensa.v0_2.activities";
	final String infoTAG = "MENSA APP STARTSCREEN";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		setContentView(R.layout.startscreen);
		
		Log.v(infoTAG, "APP STARTS HERE! JUHU!");
		
		// thread for displaying the SplashScreen
	    Thread startTread = new Thread() {
	        @Override
	        public void run() {
	        	try {
	                int waited = 0;
	                while (waited < _startTime) {
	                   sleep(100);
	                   waited += 100;
	                }
	                Log.v(infoTAG, "Done with waiting...");
	             } catch (InterruptedException e) {
	                // do nothing
	             } finally {
	                finish();
	                Intent i = new Intent();
	                i.setClassName(PAKET,
	                               PAKET + ".MainMenu");
	                Log.v(infoTAG, "The Main Menu will start now!");
	                startActivity(i);
	             }
	          }
	       };
	       startTread.start();
	}

}
